home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5294 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: cymbal.aix.calpoly.edu!not-for-mail
  2. From: dstubbs@cymbal.aix.calpoly.edu (Dan Stubbs)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Limit on #bytes inside of struct?
  5. Date: 9 Feb 1996 10:41:23 -0800
  6. Organization: California Polytechnic State University, San Luis Obispo
  7. Message-ID: <4fg4gj$4gk4@cymbal.aix.calpoly.edu>
  8. References: <4feg1d$d4g@cville-srv.wam.umd.edu>
  9. NNTP-Posting-User: dstubbs@cymbal.aix.calpoly.edu
  10.  
  11. In article <4feg1d$d4g@cville-srv.wam.umd.edu>,
  12. jeffrey d squires <jsquires@wam.umd.edu> wrote:
  13. >I have the following:
  14. >
  15. >typedef struct {
  16. >        int zero;
  17. >        int one;
  18.          ...
  19. >        int six;
  20. >        int seven_or_more;
  21. >} hist_type;
  22. >
  23. >hist_type histogram;
  24. >int num=2;
  25. >
  26. >histogram.zero = 0;
  27.     ...
  28. >histogram.four = 0;  /* at this point, value of num changes from 2 to 0!!!*/
  29. >
  30. >Is there a limit on the number of bytes allowed inside of a struct?
  31. >This is completely crazy!  
  32. >
  33. >    jsquires@umiacs.umd.edu
  34. >
  35. >
  36. I tested this by placing an array inside the struct instead of 
  37. individual items. (Sample code in another response to this post.)
  38. The result was that a segmentation fault was reported when the
  39. array, and hence the struct was too big. The value of num was 
  40. never corrupted. How big was too big?
  41.  
  42.  
  43. If the struct components must fit in one segment of memory, how
  44. big might that segment be? This is presumably system dependent.
  45. In my case it appears to be a 32MB segment. Recall that 32MB is
  46. 33,554,432 bytes. I used an array of integers (four bytes each)
  47. so the largest array would be 8,388,608 components. The actual
  48. largest array permitted was about 8,388,300 components--so the
  49. entire segment was not available for the array. Perhaps the
  50. program must fit in that segment also?
  51.  
  52.  
  53.